package com.pipi.biyesheji.dao.manager.impl;

import com.pipi.biyesheji.dao.support.PageResult;
import com.pipi.biyesheji.dao.model.CustomerDO;
import com.pipi.biyesheji.dao.query.CustomerQuery;
import com.pipi.biyesheji.dao.mapper.ext.CustomerExtMapper;
import com.pipi.biyesheji.dao.manager.CustomerManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Customer.
 */

@Component
public class CustomerManagerImpl implements CustomerManager{

    
    @Autowired
    protected CustomerExtMapper customerExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(CustomerQuery query){
        return customerExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(CustomerQuery query){
        return customerExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(Long id){
        return customerExtMapper.deleteByPrimaryKey(id);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(CustomerDO record){
        return customerExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<CustomerDO> selectByQuery(CustomerQuery query){
        return customerExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<CustomerDO> selectByQueryWithPage(CustomerQuery query) {
        PageResult<CustomerDO> result = new PageResult<CustomerDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public CustomerDO selectByPrimaryKey(Long id){
        return customerExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( CustomerDO record,  CustomerQuery query){
        return customerExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( CustomerDO record,  CustomerQuery query){

        return customerExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(CustomerDO record){
        return customerExtMapper.updateByPrimaryKeySelective(record);
    }
}